//
// Created by 66477 on 2022/10/19.
//

#ifndef DATA_STRUCTURE_TREENODE_H
#define DATA_STRUCTURE_TREENODE_H

class TreeNode {
private:
    char data = '\0';//叶子节点信息
    int weight = 1;//权值
    int parent = 0;//父节点下标
    int lch = 0;//左孩子下标
    int rch = 0;//右孩子下标
public:
    TreeNode() {}

    TreeNode(char data) : data(data) {}

    TreeNode(int weight, int lch, int rch) : weight(weight), lch(lch), rch(rch) {}

    TreeNode(char data, int weight, int parent, int lch, int rch) : data(data), weight(weight), parent(parent),
                                                                    lch(lch), rch(rch) {}

    void addW() {
        weight++;
    }

    char getData() const {
        return data;
    }

    void setData(char data) {
        TreeNode::data = data;
    }

    int getWeight() const {
        return weight;
    }

    void setWeight(int weight) {
        TreeNode::weight = weight;
    }

    int getParent() const {
        return parent;
    }

    void setParent(int parent) {
        TreeNode::parent = parent;
    }

    int getLch() const {
        return lch;
    }

    void setLch(int lch) {
        TreeNode::lch = lch;
    }

    int getRch() const {
        return rch;
    }

    void setRch(int rch) {
        TreeNode::rch = rch;
    }
};

#endif //DATA_STRUCTURE_TREENODE_H
